#include "fsl_common.h"
#include "fsl_iomuxc.h"
#include "MCIMX6Y2.h"

void clk_enable(void);
void led_init(void);
void delay_short(volatile unsigned int n);
void delay(volatile unsigned int n);
void led_on(void);
void led_off(void);

int main(void)
{

    clk_enable();
    led_init();
    while (1)
    {
        led_off();
        delay(500);
        led_on();
        delay(500);
    }
    return 0;
}
void led_on(void)
{
    GPIO1->DR &= ~(1 << 3);
}
void led_off(void)
{
    GPIO1->DR |= (1 << 3);
}
void led_init(void)
{
    IOMUXC_SetPinMux(IOMUXC_GPIO1_IO03_GPIO1_IO03, 0);
    IOMUXC_SetPinConfig(IOMUXC_GPIO1_IO03_GPIO1_IO03, 0x10b0);
    // IOMUX_SW_MUX->GPIO1_IO03 = 0x5;
    // IOMUX_SW_PAD->GPIO1_IO03 = 0x10b0;
    GPIO1->GDIR = 0x8;
    GPIO1->DR = 0x8;
}
void clk_enable(void)
{

    CCM->CCGR0 = 0xFFFFFFFF;
    CCM->CCGR1 = 0xFFFFFFFF;
    CCM->CCGR2 = 0xFFFFFFFF;
    CCM->CCGR3 = 0xFFFFFFFF;
    CCM->CCGR4 = 0xFFFFFFFF;
    CCM->CCGR5 = 0xFFFFFFFF;
    CCM->CCGR6 = 0xFFFFFFFF;
}
void delay_short(volatile unsigned int n)
{
    while (n--)
    {
    }
}
void delay(volatile unsigned int n)
{
    while (n--)
    {
        delay_short(0x7ff);
    }
}
